package springtest;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.solr.core.SolrTemplate;

@EnableAutoConfiguration
@SpringBootApplication
@Configuration
// @EnableAsync
// @EnableCasClient
public class Solr7Application {

    // 自动配置 失败 采用自定义配置

    @SuppressWarnings("deprecation")
    @Bean
    public SolrClient solrClient() {
        System.out.println("自定义配置SolrClient");
        return new HttpSolrClient("http://localhost:8060/solr");
    }

    @Bean
    public SolrTemplate solrTemplate() {
        SolrTemplate solrTemplate = new SolrTemplate(solrClient());
        return solrTemplate;
    }

    public static void main(String[] args) {
        SpringApplication.run(Solr7Application.class, args);
    }
}
